<template>
<div>
<div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll" style="transform: translate3d(0px, 0px, 0px) translateZ(0px);">
						<a :class="['mui-control-item',item.id==0?'mui-active':'']" href="#item1mobile" data-wid="tab-top-subpage-1.html" v-for="item in datalist" :key="item.id" @click="getphotodata(item.id)">
						{{item.title}}
						</a>
					
					</div>
				</div>

			</div>

			<ul class="lazyul">
  <router-link tag="li" :to="'/home/photoinfo/'+item.id" v-for="item in dataphotos" :key="item.id">
    <img v-lazy="item.img_url">
		<div class="info">
      <h4 class="infotitle">{{item.title}}</h4>
			<div class="infocontent">{{item.content}}</div>
		</div>
  </router-link>
</ul>
			
  </div>
</template>
<script>
import mui from "../../../lib/mui/js/mui.min.js";
import { Lazyload } from "mint-ui";
export default {
  data() {
    return {
      datalist: [],
      dataphotos: []
    };
  },
  created() {
    this.getinfo();
    this.getphotodata(0);
  },
  methods: {
    async getinfo() {
      const { data } = await this.$http.get("/api/getimgcategory");
      if (data.status === 0) {
        console.log(data.message);
        data.message.unshift({
          id: 0,
          title: "全部"
        });
        this.datalist = data.message;
      }
    },
    async getphotodata(id) {
      const { data } = await this.$http.get("/api/getimages/" + id);
      if (data.status === 0) {
        console.log(data.message);
        this.dataphotos = data.message;
      }
    }
  },
  mounted() {
    mui(".mui-scroll-wrapper").scroll({
      deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });
  }
};
</script>
<style lang="scss">
.mui-slider {
  touch-action: pan-x;
}
.lazyul {
  list-style: none;
  margin: 0;
  padding: 10px;
  li {
    position: relative;
    text-align: center;
    background-color: #ccc;
    box-shadow: #ccc;
    & + li {
      margin-top: 10px;
    }
    img {
      vertical-align: middle;
      width: 100%;
    }
    img[lazy="loading"] {
      width: 40px;
      height: 300px;

      margin: auto;
    }
    .info {
      position: absolute;
      color: #fff;
      bottom: 0;
      max-height: 86px;
      overflow: hidden;
      background-color: rgba(0, 0, 0, 0.5);
      .infotitle {
        font-size: 14px;
      }
      .infocontent {
        font-size: 13px;
        text-indent: 2em;
        text-align: left;
      }
    }
  }
}
</style>

